import Vue from 'vue'

var Get = function(url, callback){
    Vue.http.get(url).then(function(res){
        if(res.body.code == 200){
            if(callback && typeof(callback) == 'function') callback(res.body.data)
        }
    })
}

var Post = function(url, data, callback, error){
    Vue.http.post(url, data,).then(function(res){
        if(res.body.code == 200){
            if(callback && typeof(callback) == 'function') callback(res.body.data)
        }
        else if (res.status == 200){
            if(callback && typeof(callback) == 'function') callback(res.body)
        }
        else{
            if(error && typeof(error) == 'function') callback(res)
        }
    })
}

var Port = ''

export { Get, Post, Port }
